import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { SequelizeModule } from '@nestjs/sequelize'
import configuration from './config/config';
import { ConfigModule } from '@nestjs/config';
import { User } from './modules/users/user.model';
import { UsersController } from './modules/users/users.controller';
import { UsersService } from './modules/users/users.service';
import { UsersModule } from './modules/users/users.module';
const ENV = process.env.NODE_ENV;
@Module({
  imports: [
    ConfigModule.forRoot({
      envFilePath: !ENV ? '.env.development' : `.env.${ENV}`,
      isGlobal: true,
      load: [configuration]
    }),
    SequelizeModule.forRoot({
      dialect: 'mysql',
      host: 'localhost',
      port: 3307,
      username: 'root',
      password: 'a123',
      database: 'test',
      timezone: '+08:00',
      // host: configuration().mysql.host,
      // port: configuration().mysql.port,
      // username: configuration().mysql.username,
      // password: configuration().mysql.password,
      // database: configuration().mysql.db,
      models: [
        User
      ]
    }),
    UsersModule
  ],
  controllers: [
    AppController
  ],
  providers: [
    AppService
  ],
})
export class AppModule {}
